package com.woniu.microassetserver.mapper;

import com.woniu.microcommonsserver.entity.VendorManagementEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface VendorManagementMapper {

    /**
     * 根据参数进行分页查询
     * @param vendorManagementEntity
     * @return
     * @author luoyue
     */
    List<VendorManagementEntity> findAllByParams(@Param("vm") VendorManagementEntity vendorManagementEntity);







    /**
     * 新增供应商管理信息
     * @param vendorManagementEntity
     * @return 受影响的行数
     * @author luoyue
     */
    @Options(
            useGeneratedKeys = true,
            keyProperty = "dm.id"
    )
    @Insert("insert into vendor_management " +
            "(vendor_code,vendor_name,vendor_abbrve,vendor_type,company_telephone)" +
            " values(#{dm.vendorCode},#{dm.vendorName},#{dm.vendorAbbrve},#{dm.vendorType},#{dm.companyTelephone})")
    int saveVendorManagement(@Param("dm") VendorManagementEntity vendorManagementEntity);



    /**
     * 根据ID查询设备类型
     *
     * @param id
     * @return
     * @author luoyue
     */
    @Results({



            @Result(id = true, property = "id", column = "id", javaType = Long.class),
            @Result(property="vendorCode",column="vendor_code", javaType = String.class),
            @Result(property="vendorName",column="vendor_name", javaType = String.class),
            @Result(property="vendorAbbrve",column="vendor_abbrve", javaType = String.class),
            @Result(property="vendorType",column="vendor_type", javaType = String.class),
            @Result(property="companyTelephone",column="company_telephone", javaType = String.class),



            /*@Result(property = "customerInfo", column = "fk_customer_id", javaType = AssetsParameterBean.class, one =
            @One(select = "com.woniuxy.creditsystem.common.mapper.CustomerMapper.getOneById", fetchType = FetchType.LAZY)),*/
    })
    @Select("select * from vendor_manageent where id = #{id}")
    VendorManagementEntity getOneById(Long id);





    /**
     * 修改供应商管理
     * @param vendorManagementEntity
     * @return 受影响的行数
     */
    @Update("<script>" +
            "update vendor_management" +
            "<set>" +
            "<if test='dm.domainName != null'>" +
            "domain_name = #{dm.domainName}," +
            "</if>" +
            "</set>" +
            "where id = #{ap.id}" +
            "</script>")
    int updateVendorManagement(@Param("dm") VendorManagementEntity vendorManagementEntity);


    /**
     * 删除领域类型
     * @param id
     * @return 受影响的行数
     */

    @Delete("delete from vendor_management where id = #{id}")
    int deleteVendorManagement(@Param("id")Long id);
}
